package per.liu.model.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import per.liu.model.pojo.Deal;
import per.liu.model.pojo.DealExample;

public interface DealMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int countByExample(DealExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int deleteByExample(DealExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    @Delete({
        "delete from deal",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    @Insert({
        "insert into deal (name, price, ",
        "op_time)",
        "values (#{name,jdbcType=VARCHAR}, #{price,jdbcType=INTEGER}, ",
        "#{opTime,jdbcType=TIMESTAMP,typeHandler=per.liu.ibatis.DateTimeTypeHandler})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(Deal record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int insertSelective(Deal record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    List<Deal> selectByExample(DealExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    @Select({
        "select",
        "id, name, price, op_time",
        "from deal",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Deal selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int updateByExampleSelective(@Param("record") Deal record, @Param("example") DealExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int updateByExample(@Param("record") Deal record, @Param("example") DealExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    int updateByPrimaryKeySelective(Deal record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table deal
     *
     * @mbggenerated Wed Feb 11 15:45:43 CST 2015
     */
    @Update({
        "update deal",
        "set name = #{name,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=INTEGER},",
          "op_time = #{opTime,jdbcType=TIMESTAMP,typeHandler=per.liu.ibatis.DateTimeTypeHandler}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Deal record);
}